package cn.edu.stu.syllabus.repository.library.local;

import android.os.Parcel;
import android.os.Parcelable;

import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Index;

import cn.edu.stu.syllabus.base.Jsonable;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Transient;

/**
 * Created by daidaijie on 2017/3/27.
 */

@Entity
public class BookEntry implements Jsonable, Parcelable {

    @Id(autoincrement = true)
    private Long localId;

    @Index(unique = true)
    private Long remoteId;

    private String url;

    private String name;

    private String author;

    private String press;

    private String pressDate;

    @Transient
    private int inLibraryNum;

    @Transient
    private int sumNum;

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeValue(this.localId);
        dest.writeValue(this.remoteId);
        dest.writeString(this.url);
        dest.writeString(this.name);
        dest.writeString(this.author);
        dest.writeString(this.press);
        dest.writeString(this.pressDate);
        dest.writeInt(this.inLibraryNum);
        dest.writeInt(this.sumNum);
    }

    public Long getLocalId() {
        return this.localId;
    }

    public void setLocalId(Long localId) {
        this.localId = localId;
    }

    public Long getRemoteId() {
        return this.remoteId;
    }

    public void setRemoteId(Long remoteId) {
        this.remoteId = remoteId;
    }

    public String getUrl() {
        return this.url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAuthor() {
        return this.author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public String getPress() {
        return this.press;
    }

    public void setPress(String press) {
        this.press = press;
    }

    public String getPressDate() {
        return this.pressDate;
    }

    public void setPressDate(String pressDate) {
        this.pressDate = pressDate;
    }

    public int getInLibraryNum() {
        return this.inLibraryNum;
    }

    public void setInLibraryNum(int inLibraryNum) {
        this.inLibraryNum = inLibraryNum;
    }

    public int getSumNum() {
        return this.sumNum;
    }

    public void setSumNum(int sumNum) {
        this.sumNum = sumNum;
    }

    public BookEntry() {
    }

    protected BookEntry(Parcel in) {
        this.localId = (Long) in.readValue(Long.class.getClassLoader());
        this.remoteId = (Long) in.readValue(Long.class.getClassLoader());
        this.url = in.readString();
        this.name = in.readString();
        this.author = in.readString();
        this.press = in.readString();
        this.pressDate = in.readString();
        this.inLibraryNum = in.readInt();
        this.sumNum = in.readInt();
    }

    @Generated(hash = 1547086697)
    public BookEntry(Long localId, Long remoteId, String url, String name, String author, String press,
            String pressDate) {
        this.localId = localId;
        this.remoteId = remoteId;
        this.url = url;
        this.name = name;
        this.author = author;
        this.press = press;
        this.pressDate = pressDate;
    }

    public static final Parcelable.Creator<BookEntry> CREATOR = new Parcelable.Creator<BookEntry>() {
        @Override
        public BookEntry createFromParcel(Parcel source) {
            return new BookEntry(source);
        }

        @Override
        public BookEntry[] newArray(int size) {
            return new BookEntry[size];
        }
    };
}
